<?php
	if(!isset($_SESSION)){
		session_start();
	}

	//Clear previous messages
	if(isset($_SESSION['error'])) session_unregister('error');
	if(isset($_SESSION['success'])) session_unregister('success');
	
	//Get values from the form
	$userName = $_SESSION['userName'];
	$password = MD5(addslashes($_POST['userPassword'])); 
	
	//Validation
	if($password==""){
		$_SESSION['error']='Pleace complete the mandatory fields';
	}else{
		include('../dbConnection.php');
		if(mysql_query("UPDATE users SET userPassword = '$password' WHERE userName='$userName'")){
					$_SESSION['success'] = 'Update Successfully ';
		}else{
			$_SESSION['error'] = 'Error Occured!';
		}
	}
	$_SESSION['pages']='addUserTypes.php';
	header("location: ../../");	
?>